Tkinter change frame problem

by: sejtalk, 6 years ago


I'm creating my own program based on Harrison's tkinter course, and i have a problem with changing frames using function instead of a button. Instead of changing frames it just displays empty frame. Here's the code
class comparer(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self,*args, **kwargs)

        tk.Tk.wm_title(self, 'Comparer')
        
        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        menubar = tk.Menu(container)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label='pepe')
        filemenu.add_separator()
        filemenu.add_command(label='exit', command=quit)
        menubar.add_cascade(label='File', menu=filemenu)
        tk.Tk.config(self, menu=menubar)

        self.frames = {}

        for F in (StartPage,CheckPage,PageThree):
              frame = F(container, self)
              self.frames[F] = frame
              frame.grid(row=0, column=0, sticky="nsew")
            

      

        self.show_frame(CheckPage)

    def show_frame(self, cont):
     frame = self.frames[cont]
     frame.tkraise()



class StartPage(tk.Frame):
    
    def __init__(self, parent, controller):
        tk.Frame.__init__(self,parent)
        label = tk.Label(self, text="woke nibba hours", font=start_font)
        label.pack(pady=10,padx=10)
      
        button1 = ttk.Button(self, text='Graph Page',command=lambda: controller.show_frame(PageThree))
        button1.pack(pady=10)


class CheckPage(tk.Frame):
    
    def __init__(self, parent, controller):
        tk.Frame.__init__(self,parent)
        filelist = ['t1.txt','t2.txt','t3.txt']
        list1 = []
        for file in filelist:            
           list1.append(os.path.isfile(file))
        if all(list1):
            controller.show_frame(StartPage)
            print('xd')

        else:
            label = tk.Label(self, text="woke nibba hours", font=start_font)
            label.pack(pady=10,padx=10)




You must be logged in to post. Please login or register an account.